/**
 * @author hfutrell
 */
function testcube(){

    var vertices = [ // Front face
-1.0, -1.0, 1.0, 1.0, -1.0, 1.0, 1.0, 1.0, 1.0, -1.0, 1.0, 1.0, // Back face
 -1.0, -1.0, -1.0, -1.0, 1.0, -1.0, 1.0, 1.0, -1.0, 1.0, -1.0, -1.0, // Top face
 -1.0, 1.0, -1.0, -1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, -1.0, // Bottom face
 -1.0, -1.0, -1.0, 1.0, -1.0, -1.0, 1.0, -1.0, 1.0, -1.0, -1.0, 1.0, // Right face
 1.0, -1.0, -1.0, 1.0, 1.0, -1.0, 1.0, 1.0, 1.0, 1.0, -1.0, 1.0, // Left face
 -1.0, -1.0, -1.0, -1.0, -1.0, 1.0, -1.0, 1.0, 1.0, -1.0, 1.0, -1.0];
    
    var colors = [[1.0, 1.0, 1.0, 1.0], // Front face: white
 [1.0, 0.0, 0.0, 1.0], // Back face: red
 [0.0, 1.0, 0.0, 1.0], // Top face: green
 [0.0, 0.0, 1.0, 1.0], // Bottom face: blue
 [1.0, 1.0, 0.0, 1.0], // Right face: yellow
 [1.0, 0.0, 1.0, 1.0] // Left face: purple
];
    
    var generatedColors = [];
    
    for (j = 0; j < 6; j++) {
        var c = colors[j];
        
        for (var i = 0; i < 4; i++) {
            generatedColors = generatedColors.concat(c);
        }
    }
    
    this.cubeVerticesBuffer = gl.createBuffer();
    gl.bindBuffer(gl.ARRAY_BUFFER, this.cubeVerticesBuffer);
    gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(vertices), gl.STATIC_DRAW);
    
    this.cubeVerticesColorBuffer = gl.createBuffer();
    gl.bindBuffer(gl.ARRAY_BUFFER, this.cubeVerticesColorBuffer);
    gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(generatedColors), gl.STATIC_DRAW);
    
    this.cubeVerticesIndexBuffer = gl.createBuffer();
    gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.cubeVerticesIndexBuffer);
    
    // This array defines each face as two triangles, using the
    // indices into the vertex array to specify each triangle's
    // position.
    
    var cubeVertexIndices = [0, 1, 2, 0, 2, 3, // front
 4, 5, 6, 4, 6, 7, // back
 8, 9, 10, 8, 10, 11, // top
 12, 13, 14, 12, 14, 15, // bottom
 16, 17, 18, 16, 18, 19, // right
 20, 21, 22, 20, 22, 23 // left
]
    
    // Now send the element array to GL
    gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, new Uint16Array(cubeVertexIndices), gl.STATIC_DRAW);
    
   // console.log("created a friggen cube");
    
}

testcube.prototype.cubeVerticesIndexBuffer = null;
testcube.prototype.cubeVerticesColorBuffer = null;
testcube.prototype.cubeVerticesBuffer = null;

testcube.prototype.draw = function(positionAttrib, colorsAttrib){

    gl.bindBuffer(gl.ARRAY_BUFFER, this.cubeVerticesBuffer);
    gl.vertexAttribPointer(positionAttrib, 3, gl.FLOAT, false, 0, 0);
	
    // Set the colors attribute for the vertices.
   // gl.bindBuffer(gl.ARRAY_BUFFER, this.cubeVerticesColorBuffer);
   // gl.vertexAttribPointer(colorsAttrib, 4, gl.FLOAT, false, 0, 0);
    
    // Draw the cube.
    gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.cubeVerticesIndexBuffer);
		
	gl.enableVertexAttribArray(positionAttrib);
	
    gl.drawElements(gl.TRIANGLES, 36, gl.UNSIGNED_SHORT, 0);

	
        
};

